package com.radiant.data.entity;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.google.inject.Inject;

@XmlRootElement
public class CommentLike extends Like {

	@Inject
	private CommentDAO commentDAO;

	@XmlTransient
	private Comment comment;

	public CommentLike() {
		super();
	}

	public CommentLike(Comment comment) {
		this.comment = comment;
	}

	@Override
	protected void setParentFromString(String parent) {
		comment = commentDAO.findByPrimaryKey(parent, true);
	}

	@Override
	protected String getParentAsString() {
		return comment.getCommentId();
	}

	@Override
	public void addToActivity(Activity activity) {
		Post post = comment.getPost();
		activity.setPost(post);
	}

	@Override
	public void addMessageToActivity(Activity activity, User creator,
			Child child) {
		StringBuffer sb = new StringBuffer();
		sb.append(creator.getUserName()).append(" liked ");
		sb.append("comment owner's").append("comment");
		sb.append("post owner's").append("post");
		activity.setMessage(sb.toString());
	}


}
